package com.gt.web.srv.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 积分变动类型枚举  1收入 2支出
 *
 * @author Yu Chaohua
 * @date 2024/5/24 0:46
 */
@Getter
@AllArgsConstructor
public enum TradeScoreTypeEnum {

    ADD(1, "收入"),
    SUB(2, "支出");

    private Integer code;

    private String desc;

    private static final Map<Integer, TradeScoreTypeEnum> CODE_MAP = new HashMap<>((int) (values().length / .75f) + 1);

    static {
        for (TradeScoreTypeEnum item : values()) {
            CODE_MAP.put(item.code, item);
        }
    }

    public static TradeScoreTypeEnum fromCode(Integer code) {
        return CODE_MAP.get(code);
    }
}
